<div class="page-container" v-cloak>
    <el-card>
        <template #header>
            <div class="breadcrumb" style=" overflow: hidden;">
                <el-breadcrumb separator="/" style=" float: left;  ">
                    <el-breadcrumb-item><a href="{:url('admin/goodstype/index')}">标签列表</a></el-breadcrumb-item>
                    <el-breadcrumb-item>{$title}</el-breadcrumb-item>
                </el-breadcrumb>
                <el-breadcrumb separator="/" style=" float: right;  ">
                    <el-button type="primary" @click="refresh()">刷新</el-button>
                </el-breadcrumb>
            </div>
        </template>
        <div>
            <el-form label-width="100px">
                <el-form-item label="分类">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item>
                        <el-button @click="submitEvent" type="primary">
                        提交
                    </el-button>
                    <el-button @click="goBack" type="warning">
                        返回
                    </el-button>
                </el-form-item>
            </el-form>
        </div>
    </el-card>
</div>

<script>
    const App = {
        data() {
            return {
                form: {}
            }
        },
        mounted() {
            this.getInfo()
        },
        computed: {},
        methods: {

            /**
             * 获取编辑所需信息
             */
            getInfo() {
                let goods_type_id = this.getUrlQuery('goods_type_id', 0)
                this.httpGet("{:url('admin/goodstype/edit')}/" + goods_type_id, {}).then(res => {
                    if (res.status) {
                        let {room_label = {}} = res.data
                        if (room_label.goods_type_id) {
                            this.form = {
                                ...room_label,
                            }
                        }
                    }
                })
            },
            /**
             * 提交信息
             */
            submitEvent() {
                this.httpPost("{:url('admin/goodstype/edit')}", {
                    ...this.form,
                }, true).then(res => {
                    if (res.status) {
                        this.$message.success(res.msg)
                        location.href = "{:url('admin/goodstype/index')}"
                    }
                })
            },
            refresh() {
                location.replace(location.href);
            },
            goBack() {
                window.history.back();
            }
        }
    }
</script>

<style>
</style>
